package com.neusoft.hifly.core.token.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * JSON Web Token配置信息
 */
@Component
public class JwtConfig {
	// 是否启用
	@Value("${jwt.enable:false}")
	private boolean enable;

	// 是否测试环境
	@Value("${jwt.test:false}")
	private boolean test;

	// 登录地址
	@Value("${jwt.login-url:null}")
	private String loginUrl;

	// 过期时间(单位秒) ，8小时 = 8 * 60 * 60 = 28800
	@Value("${jwt.expire:28800}")
	private long expire;

	// 需要认证的url，多个URL使用英文逗号,分割
	@Value("${jwt.authoriseds:/api/**}")
	private String[] authorisedUrls;

	// 忽略的url，多个URL使用英文逗号,分割
	@Value("${jwt.excludes:/api/auth/login,/api/auth/logout,/api/auth/refresh}")
	private String[] excludeUrls;

	public boolean isEnable() {
		return enable;
	}

	public void setEnable(boolean enable) {
		this.enable = enable;
	}

	public boolean isTest() {
		return test;
	}

	public void setTest(boolean test) {
		this.test = test;
	}

	public String getLoginUrl() {
		return loginUrl;
	}

	public void setLoginUrl(String loginUrl) {
		this.loginUrl = loginUrl;
	}

	public long getExpire() {
		return expire;
	}

	public void setExpire(final long expire) {
		this.expire = expire;
	}

	public String[] getAuthorisedUrls() {
		return authorisedUrls;
	}

	public void setAuthorisedUrls(final String[] authorisedUrls) {
		this.authorisedUrls = authorisedUrls;
	}

	public String[] getExcludeUrls() {
		return excludeUrls;
	}

	public void setExcludeUrls(final String[] excludeUrls) {
		this.excludeUrls = excludeUrls;
	}

}